﻿using phpMyAdminToolkit.Dump;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Data;

namespace phpMyAdminToolkit.Tests
{


	/// <summary>
	///This is a test class for phpMyAdminDumperTest and is intended
	///to contain all phpMyAdminDumperTest Unit Tests
	///</summary>
	[TestClass()]
	public class phpMyAdminDumperTest
	{


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion


		/// <summary>
		///A test for Dump
		///</summary>
		[TestMethod()]
		[DeploymentItem("phpMyAdminToolkit.TestDataSource.xls")]
		[DataSource("System.Data.OleDb",
		   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=phpMyAdminToolkit.TestDataSource.xls;Persist Security Info=False;Extended Properties=\"Excel 8.0\"",
		   "Dump$",
		   DataAccessMethod.Sequential)]
		public void DumpTest()
		{
			phpMyAdminDumper target = new phpMyAdminDumper();

			DataRow dataRow = TestContext.DataRow;
			Uri pmaUri = new Uri(dataRow["phpMyAdmin Uri"].ToString());
			string user = dataRow["User"].ToString();
			string password = dataRow["Password"].ToString();
			string databaseName =dataRow["Database Name"].ToString();
			string backupDirectory = dataRow["Backup Directory"].ToString();
			string sqlCommand = dataRow["SQL Command"].ToString();
			string excludedTables = dataRow["Excluded Tables"].ToString();
			string includedTables = dataRow["Included Tables"].ToString();

			target.Dump(pmaUri, user, password, databaseName, backupDirectory, sqlCommand, includedTables, excludedTables);
		}
	}
}
